package com.ps.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ps.property.TOtherLike;
import com.ps.service.LikeService;
import com.ps.store.LikeStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author gt
 * @类说明：
 * @date 2020/10/27 19:23
 */
@Service
public class LikeServiceImpl implements LikeService {
    @Autowired
    LikeStore likeStore;

    @Override
    public int likeAdd(TOtherLike tOtherLike) {
        return likeStore.insert(tOtherLike);
    }

    @Override
    public IPage<TOtherLike> likeQuery(int currentPage, int pageSize) {
        IPage iPage = new Page(currentPage,pageSize);

        iPage = likeStore.selectPage(iPage,null);

        return iPage;
    }

    @Override
    public TOtherLike likeQueryById(int likeId) {
        QueryWrapper queryWrapper = new QueryWrapper();

        queryWrapper.eq("id",likeId);

        return likeStore.selectOne(queryWrapper);
    }

    @Override
    public int likeUpdate(TOtherLike tOtherLike) {
        return likeStore.updateById(tOtherLike);
    }
}
